<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .countDown{
            width: 100px;
            height: 80px;
            font-size: 26px;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- 倒计时：countDown -->
        <button class="countDown" :countDown="countDown" @click="dj">{{num}}</button>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                num:6, //默认倒计时事件
                countDown:true, //默认不能点击
            },
            methods:{
                //点击函数
                dj:function(){
                    // console.log("点击");
                    alert("点击")
                },
            },
            //定义自执行函数
            mounted(){ 
                var djs = this.num;  //变量接收倒计时
                var timer = setInterval(function(){ //变量接收定时器
                    djs--
                    this.num = djs; 
                    if(0 == djs){
                        this.countDown = false //改变点击状态可点
                        clearInterval(timer)  
                        this.num = "提交"
                    }
                }.bind(this),1000)
            }
        });
    </script>
</body>
</html>